<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/admin/include/head.htm">
<script type="text/javascript">
	var grid;
	$(function(){
		 grid = $("#maingrid").ligerGrid({
            columns: [
			{name: 'id', hide: true, width:0, isAllowHide: false},
			{display: '字典编码', name: 'decode', align: 'left', width: 100 },
			{display: '字典名称', name: 'name', align: 'center', width: 300 },
			{display: '字典描述', name: 'description', align: 'center', width: 300 }
			],  pageSize:20, url: '${base}/admin/system/dictionary/queryData.jhtml?parentCode=${(parentCode)!""}',usePager:false,
			toolbar: {}, width: '100%', height:'100%', enabledSort: true
        });
        //双击事件(id:为点击操作的id)
      	LG.setGridDoubleClick(grid, 445);
        $("#pageloading").hide();
		LG.loadToolbar(grid);
		
		//绑定搜索按钮
		LG.search(grid);
	});
	
	function add(){
		top.f_addTab(null,'新增数据字典', base + '/admin/system/dictionary/add.jhtml?parentCode=${(parentCode)!""}');
	}
	
	function edit(){
		var selecteds = grid.getSelecteds();
		if (selecteds.length != 1) { 
			LG.tip('请选择一行记录!'); return; 
		}
		var decode = selecteds[0].decode;
		if(top.f_isTabItemExist("dictionary" + decode)){
			top.f_switchTab("dictionary" + decode);
		}else{
			top.f_addTab("dictionary" + decode, '修改数据字典[' + selecteds[0].name + ']', base + '/admin/system/dictionary/edit/'+decode+".jhtml");
		}
	}
	
	function f_delete(){
		var selecteds = grid.getSelecteds();
	    if (selecteds.length > 0) {
		    jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
				if (confirm){
					var decodes = [];
					for(var i =0;i <selecteds.length;i++){
						decodes.push(selecteds[i].decode);
					}
					LG.ajax({
						url: base + '/admin/system/dictionary/delete.jhtml',
			            loading: '正在删除中...',
			            data: { decodes: decodes.join(',') },
			            success: function () {
							LG.showSuccess('删除成功');
			                f_reload();
			                for(var i = 0;i <decodes.length;i++){
			               	 	window.parent.leftFrame.removeNode(decodes[i]);
			                }
			            },
			            error: function (message) {
							LG.showError(message);
			            }
	        		});
	        	}
	        });
		} else {
			LG.tip('请选择行!');
	    }
	}
	
	function reinit(){
		jQuery.ligerDialog.confirm('确定重新初始化吗?', function (confirm) {
			if (confirm){
				LG.ajax({
					url: base + '/admin/system/dictionary/reinit.jhtml',
		            loading: '正在初始化中...',
		            data: { },
		            success: function () {
						LG.showSuccess('初始化成功');
		                f_reload();
		            },
		            error: function (message) {
						LG.showError(message);
		            }
		        });
		   }
		});
	}
</script>
</head>
<body style="padding:10px; overflow:hidden;">
	<div id="maingrid" style="margin:0; padding:0"></div>
</body>
</html>